<!-- 首页 -->
<template>
    <view class="home-wrap u-m-b-20">

        <!-- #ifdef APP-PLUS -->
        <u-no-network @retry="init"></u-no-network>
        <!-- #endif -->
        <view class="content-box">


                <view class="collect-list" style="font-size: 30rpx;">
                    <u-notice-bar v-if="task_status!=0" mode="horizontal" :list="noticList" :color="'#1793f8'" :bgColor="'#b2e8f8'" :autoplay="false"></u-notice-bar>
                    <view class="zixun-item u-flex u-flex-col u-p-20">
                        <view class="u-flex u-row-between u-flex-col u-col-center u-w-100s">
                            <view class="u-flex u-row-between u-col-center u-w-100s">
                                <view class="u-flex u-flex-col u-row-left">
                                    <view class="u-flex u-row-left u-m-b-20" style="width: 100%;">
                                        <view class="kehulsit u-ellipsis-1">{{ '异常单号' }}:</view>
                                        <view class="kehulsit u-ellipsis-1 u-m-l-16 u-m-r-16" style="color:#666666;">{{
                                            taskInfo.operation_no }}
                                        </view>
                                        <view class="user_img u-m-r-10" @click="copyCode(taskInfo.operation_no)">
                                            <image style="width: 40rpx;height: 40rpx;border-radius: 50%" src="/static/images/copy.png"></image>
                                        </view>
                                    </view>
                                </view>
                            </view>
                            <view class="u-flex u-row-left u-m-b-20" style="width: 100%;" v-if="taskInfo.exception_category">
                                <view class="kehulsit u-ellipsis-1">{{ '异常类型' }}:</view>
                                <view class="kehulsit u-ellipsis-1 u-m-l-16 u-m-r-16" style="color:#666666;">{{
                                    taskInfo.exception_category.join(">") }}
                                </view>
                            </view>
                            <view class="u-flex u-row-left u-m-b-20" style="width: 100%;">
                                <view class="kehulsit u-ellipsis-1">{{ '异常地点' }}:</view>
                                <view class="kehulsit u-ellipsis-1 u-m-l-16 u-m-r-16" style="color:#666666;">{{
                                    taskInfo.address }}
                                </view>
                                <view class="user_img u-m-r-10" @click.stop="goLoaction">
                                    <image style="width: 40rpx;height: 40rpx;border-radius: 50%" src="/static/images/daohang.png"></image>
                                </view>
                            </view>
                            <view class="u-flex u-row-left u-m-b-20" style="width: 100%;">
                                <view class="kehulsit u-ellipsis-1">{{ '上报人员' }}:</view>
                                <view class="kehulsit u-ellipsis-1 u-m-l-16 u-m-r-16" style="color:#666666;">{{
                                    taskInfo.user.realname }}
                                </view>
                                <view class="user_img u-m-r-10" @click.stop="telphone(taskInfo.user.mobile)">
                                    <image style="width: 40rpx;height: 40rpx;border-radius: 50%" src="/static/images/phone.png"></image>
                                </view>
                            </view>
                            <view class="u-flex u-row-left" style="width: 100%;">
                                <view class="kehulsit u-ellipsis-1">{{ '上报时间' }}:</view>
                                <view class="kehulsit u-ellipsis-1 u-m-l-16 u-m-r-16" style="color:#666666;">{{
                                    taskInfo.create_time }}
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="u-flex u-flex-col u-w-100s u-m-t-20">
                    <view class="userInfo u-flex u-row-between u-col-center u-w-100s">
                        <view class="userleft u-flex u-row-left u-col-center u-w-100s u-p-l-20">
                            <view class="usertitle">差异信息:</view>
                        </view>
                    </view>
                    <view class="collect-list u-w-100s u-p-20 u-flex u-flex-wrap u-row-between">
                        <view class="u-m-t-20" v-for="(item,index) in JSON.parse(taskInfo.images)" :key="index" style="width: 48%;height: 220rpx;">
                            <image :src="item" style="width: 100%;height: 100%;"></image>
                        </view>
                    </view>
                </view>
                <view class="u-flex u-flex-col u-w-100s u-m-t-20">
                    <view class="userInfo u-flex u-row-between u-col-center u-w-100s">
                        <view class="userleft u-flex u-row-left u-col-center u-w-100s u-p-l-20">
                            <view class="usertitle">备注信息:</view>
                        </view>
                    </view>
                    <view class="collect-list u-w-100s u-p-20" style="color:#666666;font-size:30rpx;">
                        {{ taskInfo.description }}
                    </view>

                </view>
                            <view class="u-flex u-flex-col u-w-100s u-m-t-20">
                                <view class="userInfo u-flex u-row-between u-col-center u-w-100s">
                                    <view class="userleft u-flex u-row-left u-col-center u-w-100s u-p-l-20">
                                        <view class="usertitle">异常照片</view>
                                    </view>
                                </view>
                                <view class="collect-pages-list u-w-100s u-m-t-20 u-flex u-flex-wrap u-row-between">

                                    <view class="img-box" v-if="task_status==0">
                                        <u-upload
                                            :showProgress="false"
                                            @on-uploaded="uploadSuccess"
                                            @on-remove="uploadRemove"
                                            :action="`${$BASE_URL}/upload/uploadImage`"
                                            :header="header"
                                            width="220"
                                            maxSize="10,485,760"
                                            height="220"
                                            maxCount="9"
                                        ></u-upload>
                                    </view>
                                    <view class="u-m-t-20" v-for="(item,index) in yichangImages" :key="index" style="width: 48%;height: 220rpx;" v-if="task_status!=0">
                                        <image :src="item" style="width: 100%;height: 100%;"></image>
                                    </view>
                                </view>
                            </view>

            <view class="u-flex u-row-around u-w-100s u-m-t-60 u-p-b-80" v-if="task_status==0">
                <view class="userInfo-btn u-flex u-row-center u-col-center" @tap="showyichangPopu()">
                    <view class="btn-btom" >未发现异常</view>
                </view>
                <view class="userInfo-btn2 u-flex u-row-center u-col-center" @tap="showHeshiPopu()">
                    <view class="btn-btom">核实完成</view>
                </view>
            </view>
            <!-- 未发现异常 -->
            <u-popup v-model="showyichang" mode="center" border-radius="20" :closeable="true" close-icon-pos="top-right">
                <view class="notice-modal">
                    <view class="notice-title">{{ "是否未发现异常" }}</view>
                    <view class="u-flex u-row-around u-w-100s">
                        <button class="u-reset-button back-btn" @tap="closePopu('showyichang')">取消</button>
                        <button class="u-reset-button notice-btn" @tap="heShi('2')">确认</button>
                    </view>
                </view>
            </u-popup>
            <!-- 核实完成 -->
            <u-popup v-model="showHeshi" mode="center" border-radius="20" :closeable="true" close-icon-pos="top-right">
                <view class="notice-modal">
                    <view class="notice-title">{{ "是否核实完成" }}</view>
                    <view class="u-flex u-row-around u-w-100s">
                        <button class="u-reset-button back-btn" @tap="closePopu('showHeshi')">取消</button>
                        <button class="u-reset-button notice-btn" @tap="heShi('1')">确认</button>
                    </view>
                </view>
            </u-popup>
            <!-- 权限验证 -->
            <u-popup v-model="showTetel" mode="center" border-radius="20" :closeable="true" close-icon-pos="top-right">
                <view class="notice-modal">
                    <view class="notice-title">{{ "是否拨打"+telenum }}</view>
                    <view class="u-flex u-row-around u-w-100s">
                        <button class="u-reset-button back-btn" @tap="closePopu('showTetel')">取消</button>
                        <button class="u-reset-button notice-btn" @tap="callPhone()">确认</button>
                    </view>
                </view>
            </u-popup>
        </view>
    </view>
</template>

<script>

let systemInfo = uni.getSystemInfoSync();
import { mapMutations, mapActions, mapState, mapGetters } from 'vuex';
export default {
    components: {

    },
    data() {
        return {
            task_status  : '',
            showTetel:false,
            showyichang:false,
            showHeshi:false,
            telenum      : '',
            keyword:'',
            taskInfo     :
            {

            },
            kehuDetail:[],
            isEmpty:false,
            searchVal:'',
            loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
            currentPage: 1,
            lastPage: 1,
            stickyTop: 0,
            show:false,
            token: uni.getStorageSync('token'),
            yichangImages: [],
            task_id      : '',
            newImages    : [],
            noticList    : [],
	        header:{'Authorization': 'Bearer' + ' ' +uni.getStorageSync('token')}
        };
    },
    computed: {

    },
    async onLoad() {
        this.task_id     = this.$Route.query.task_id;
        this.task_status = this.$Route.query.status;
        let task_status  = this.task_status + "审核完成";
        this.noticList.push(task_status)
        this.getmyKehuDetail();
    },
    created() {
    },
    onPullDownRefresh() {
    },
    oonPageScroll(e) {

    },
    onShow() {
    },
    onHide() {

    },
    mounted() {
	    console.log("===header",this.header)
    },

    watch: {

    },
    methods: {
        goLoaction(){
            uni.openLocation({
                latitude: Number(this.taskInfo.latitude),
                longitude: Number(this.taskInfo.longitude),
                name: this. taskInfo.address,
                address: this.taskInfo.address,
                success: function () {
                    console.log('success');
                }
            });
        },
        closePopu(type){
            if(type == "showyichang"){
                this.showyichang = false;
            }
            if(type == "showHeshi"){
                this.showHeshi = false;
            }
            if(type == "showTetel"){
                this.showTetel = false;
            }
        },
        callPhone(){
          this.$tools.callPhone(this.telenum)
        },
        showyichangPopu(){
          this.showyichang = true;
        },
        showHeshiPopu(){
           this.showHeshi = true;
        },
// 上传图片成功
        uploadSuccess(e) {
            this.yichangImages = [];
	        console.log("===e",e,JSON.stringify(e))
	        
            e.forEach(item => {
                this.yichangImages.push(item.response.data);
            });
        },
        heShi(type) {
            var that        = this;
            that.heShi_type = type;
            that.$http('login.jiheSave', {
                id : that.task_id,
                res: that.heShi_type,
	            credential:that.yichangImages
            }).then(res => {
                uni.showToast({
                	title: res.msg,
                	icon: 'none',
                	duration: 1000,
                	mask: true
                });
                uni.navigateBack();
            });
        },
        copyCode(code) {
            let that = this;
            uni.setClipboardData({
                data   : code,
                success: () => {
                    that.$u.toast('已复制到剪切板');
                }
            });
        },
        // 移除图片
        uploadRemove(index) {
            this.yichangImages.splice(index, 1);
        },
        getmyKehuDetail() {
            let that = this;
            that.$http('login.taskInfo', {
                id: that.task_id
            }).then(res => {
                // let phone           = JSON.parse(JSON.stringify(res.data.phone))
                // res.data.phones         = phone.replace(/^(\d{3})\d{4}(\d+)/, "$1****$2");
                // res.data.names = res.data.name.charAt(0) + that.idCard(res.data.idcard)
                console.log("====", JSON.parse(res.data.images))
                that.taskInfo = res.data;
	            that.yichangImages = JSON.parse(that.taskInfo.credential);
                console.log("====res.data.images", that.taskInfo)
            });
        },
        //通过身份证号计算性别
        idCard(userCard) {
            //获取性别
            // if (parseInt(userCard.substr(16, 1)) % 2 == 1) {
            //     return "男士";
            // } else {
            //     return "女士";
            // }
        },

        telphone(num){
            this.showTetel = true;
            this.telenum = num
            console.log("==taskInfo.user.mobile",this.taskInfo.user.mobile)
        },
        // 初始化
        init() {
            this.isRefresh = false;
        },

        // 路由跳转
        jump(path, parmas) {
            console.log('-----11111');
            this.$Router.push({
                path: path,
                query: parmas
            });
        },
    }
};
</script>

<style lang="scss">
.home-wrap{
}
.bianji{
    width: 90%;
    background: #0081ff;
    border-radius: 30rpx;
    color:#fff;
}
.input-item{
    color:#333;
    margin:20rpx 0rpx 20rpx 20rpx;
    height: 84rpx;
    background: #FFFFFF;
    border-radius: 30rpx;
    text-indent: 14rpx;
}
//nav
.zixun-item {
    background: #fff;

    .zixuntitle {
        color: #333;
        font-size: 28rpx;
    }

    .zixunimg {
        width: 100%;
        height: 180rpx;

        image {
            width: 100%;
            height: 100%;
        }
    }

    .zixuntime {
        color: #cccccc;
        font-size: 24rpx;
    }

    .yichu {
        padding: 16rpx 26rpx;
        border-radius: 34rpx;
        background: #0081ff;
        color: #fff;
    }

    .tag {
        color: #fff;
        padding: 6rpx 18rpx;
        font-size: 20rpx;
        border-radius: 20rpx;
        border: 2rpx solid transparent;
        margin-right: 10rpx;
    }
}
.userInfo{
    .userleft{
        .usertitle{
            font-size:30rpx;
        }
    }
    .userright{
        padding:10rpx 24rpx;
        background: #0081ff;
        border-radius: 30rpx;
        color: #FFFFFF;
    }

}
// 提示
.notice-modal {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    width: 85vw;
    min-height: 358rpx;
    background: #ffffff;
    padding: 30rpx;
    border-radius: 20rpx;

    .notice-title {
        width: 100%;
        font-size: 30rpx;
        font-weight: bold;
        color: #46351b;
        text-align: center;
    }

    .notice-detail {
        font-size: 24rpx;
        font-weight: 400;
        color: #999999;
        line-height: 36rpx;
        margin-bottom: 50rpx;
    }

    .back-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        background: #f8f8f8;
        box-shadow: 0 7rpx 8rpx 2rpx #ccc;
        border-radius: 35rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #333;
        margin-bottom: 10rpx;
    }

    .notice-btn {
        width: 45%;
        height: 70rpx;
        line-height: 70rpx;
        font-size: 26rpx;
        font-weight: 500;
        color: #fff;
        border-radius: 35rpx;
        background: linear-gradient(90deg, #3357DB 0%, #3469E1 47%, #3597F1 100%);
        box-shadow: 0 7rpx 8rpx 2rpx #3597F1;
    }
}
::v-deep .u-add-wrap{
   border: 2rpx dashed #999;
}
.userInfo-btn{
    width: 40%;
    height: 80rpx;
    color:#3597F1;
    border: 2rpx solid #3597F1;
}
.userInfo-btn2{
    width: 40%;
    height: 80rpx;
    color: #fff;
    background: #3597F1;
    border: 2rpx 2rpx solid #3597F1;
}
</style>
